#ifndef _IM_SERVER_COMET_SERVER_
#define _IM_SERVER_COMET_SERVER_

#include <boost/asio.hpp>

#include "comet_connection.h"
#include "comet_message_outlet_service.h"

using namespace boost::asio;

namespace imserver {

extern boost::asio::io_service g_io_service;
extern time_t g_alive_since;
extern int g_shard_id;

class CometServer {
public:
  CometServer(boost::asio::io_service& io_service, int port)
    : acceptor_(io_service, ip::tcp::endpoint(ip::tcp::v4(), port))
  {
    StartAccept();
  }

private:
  void StartAccept();
  void HandleAccept(CometConnectionPtr new_connection,
      const boost::system::error_code& error);

  ip::tcp::acceptor acceptor_;
};

}

#endif // _IM_SERVER_COMET_SERVER_
